import 'package:flutter/material.dart';
import 'package:flutter_quick/components/chat-message/msg-box.dart';

class MsgItem extends StatelessWidget {
  Widget content;
  String avatar;
  String name;

  MsgItem({
    Key? key,
    required this.content,
    required this.avatar,
    required this.name,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 10, right: 10, bottom: 12),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            width: 38,
            height: 38,
            transform: Matrix4.translationValues(0, 3, 0),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(6)),
              image: DecorationImage(
                image: NetworkImage(avatar),
                fit: BoxFit.cover,
              ),
            ),
          ),
          Expanded(
            child: Container(
              margin: EdgeInsets.only(left: 10),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                // 名称
                children: [
                  Container(
                    margin: EdgeInsets.only(bottom: 3),
                    child: Text(
                      name,
                      style: TextStyle(
                        color: Color(0xff858585),
                        fontSize: 11,
                      ),
                    ),
                  ),
                  // 内容
                  MsgBox(child: content)
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}
